<template>

  <el-dialog
    title="预收款收支详细信息"
    :visible.sync="dialogVisible"
    width="50%"
  >
    <el-table
      :data="tableData"
      style="width: 100%"
      border
      show-overflow-tooltip
    >
      <el-table-column
        prop="ruSysNo"
        label="单号"
        show-overflow-tooltip
      >
        <!-- <template slot-scope="scope">
          {{scope.row[payTypeMap[scope.row.payType][3]]}}
        </template> -->
        <template slot-scope="scope">
           <span v-if="scope.row.ruSysNo!=null&&scope.row.ruSysNo!=''">{{scope.row.ruSysNo}}</span>
             <span v-else>{{scope.row.sysOrderNum}}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="banks"
        label="房间号"
      >
      <template slot-scope="scope">
         <span v-if="scope.row.banks!=null&&scope.row.banks!=''">{{scope.row.banks}}</span>
           <span v-else>POS</span>
      </template>
      </el-table-column>
      <el-table-column
        prop="payType"
        label="项目名称"
      >
        <template slot-scope="scope">
          {{payTypeMap[scope.row.payType][0]}}
        </template>
      </el-table-column>
      <el-table-column
        prop="consumeInfo"
        label="付款方式"
      >
      </el-table-column>
      <el-table-column
        prop="payPrice"
        label="金额"
      >
        <template slot-scope="scope">
          <el-tag :type="payTypeMap[scope.row.payType][1]">
            {{payTypeMap[scope.row.payType][2]+scope.row.payPrice}}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column
        prop="creatTime"
        label="发生时间"
        width="100px"

      >
      </el-table-column>
      <el-table-column
        prop="turnPeopleId"
        label="转账账号"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="remarks"
        label="备注"
      >
      </el-table-column>
      <el-table-column
        prop="banksNumber"
        label="操作员"
      >
      </el-table-column>

    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[5,10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper"
    ></el-pagination>
  </el-dialog>

</template>

<script>
import Moment from 'moment'
export default {
  data () {
    return {
      accounts: [],
      type: '',
      time: '',
      dialogVisible: false,
      tableData: [],
      pageIndex: 1,
      pageSize: 5,
      totalPage: 0,
      isDay: '日',
      payTypeMap: {
        // a.collection_no `collection_no`,
        // a.refund_no `refund_no`,
        // a.inpOrder_num `inpOrder_num`,
        0: ['预收款账', 'success', '', 'ruSysNo'],
        5: ['预收退款', 'danger', '-', 'refundNo'],
        6: ['结账收款', 'success', '', 'ruSysNo'],
        7: ['结账退款', 'danger', '-', 'refundNo'],
        3: ['押金收款', 'success', '', 'ruSysNo'],
        8: ['押金退款', 'danger', '-', 'refundNo']
      },

    }
  },
  methods: {
    init (type, time, isDay) {
      this.tableData = []
      this.pageIndex = 1,
        this.pageSize = 5,
        this.totalPage = 0,
        this.dialogVisible = true
      this.type = type
      this.time = time
      this.isDay = isDay
      this.getAccountData()
    },
    getAccountData () {
      this.dialogVisible = true
      console.log("time", this.time)
      if (this.isDay == "日") {
        this.time = Moment(this.time).format('YYYY-MM-DD')
      }
      if (this.isDay == "月") {
        this.time = Moment(this.time).format('YYYY-MM')
      }
      this.$http({
        url: this.$http.adornUrl('/hotel/thotelfloorroomcheckinaccounting/reportForm'),
        method: 'get',
        params: this.$http.adornParams({
          page: this.pageIndex,
          limit: this.pageSize,
          type: this.type,
          time: this.time,
          isDay: this.isDay,
        })
      }).then(({ data }) => {
        if (data && data.code === 0) {
          console.log(data)
          this.tableData = data.accounts.records
          this.totalPage = data.accounts.total;
        } else {

        }
      })
    },

    filterTime (row, column, cellValue, index) {
      return Moment(row.time).format('YYYY-MM-DD')
    },
    // 每页数
    sizeChangeHandle (val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getAccountData();
    },
    // 当前页
    currentChangeHandle (val) {
      this.pageIndex = val;
      this.getAccountData();
    },
  }
}
</script>
